package com.juyu.miliao.api.dao.mysql;

import com.juyu.miliao.api.domain.DynamicCommentInfo;
import com.juyu.miliao.api.domain.WhitePacketCommentReplyInfo;
import com.juyu.miliao.api.domain.WhitePacketDynamicCommentInfo;
import com.juyu.miliao.api.domain.WhitePacketDynamicInfo;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author xuanqicheng
 * @create 2019-21-13:06
 */
@Repository
public class WhitePacketDynamicCommentInfoDao {

    @Autowired
    private SqlSession sqlSession;

    public void addDynamicComment(WhitePacketDynamicCommentInfo dynamicCommentInfo) {
        sqlSession.insert("addWhitePacketDynamicComment",dynamicCommentInfo);
    }

    public WhitePacketDynamicCommentInfo getDynamciCommentById(long id) {
        return sqlSession.selectOne("getWhitePacketDynamciCommentById",id);
    }

    public int getDynamicCommentCountByDynamicId(long dynamicId) {
        return sqlSession.selectOne("getWhitePacketDynamicCommentCountByDynamicId",dynamicId);
    }

    public List<WhitePacketDynamicCommentInfo> getDynamicCommentPageByDynamicId(long dynamicId, int startNum, int pageSize) {
        Map<String,Object> map = new HashMap<>(3);
        map.put("dynamicId",dynamicId);
        map.put("startNum",startNum);
        map.put("pageSize",pageSize);
        return sqlSession.selectList("getWhitePacketDynamicCommentPageByDynamicId",map);
    }

}
